package com.qujia.markert.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qujia.common.annotation.Log;
import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.common.enums.BusinessType;
import com.qujia.markert.domain.ReductionOilRelations;
import com.qujia.markert.service.IReductionOilRelationsService;
import com.qujia.common.utils.poi.ExcelUtil;
import com.qujia.common.core.page.TableDataInfo;

/**
 * 立减活动和油品关系Controller
 * 
 * @author qujia
 * @date 2021-11-02
 */
@RestController
@RequestMapping("/market/reductionOilRelations")
public class ReductionOilRelationsController extends BaseController
{
    @Autowired
    private IReductionOilRelationsService reductionOilRelationsService;

    /**
     * 查询立减活动和油品关系列表
     */
    @PreAuthorize("@ss.hasPermi('market:reductionOilRelations:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReductionOilRelations reductionOilRelations)
    {
        startPage();
        List<ReductionOilRelations> list = reductionOilRelationsService.selectReductionOilRelationsList(reductionOilRelations);
        return getDataTable(list);
    }

    /**
     * 导出立减活动和油品关系列表
     */
    @PreAuthorize("@ss.hasPermi('market:reductionOilRelations:export')")
    @Log(title = "立减活动和油品关系", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ReductionOilRelations reductionOilRelations)
    {
        List<ReductionOilRelations> list = reductionOilRelationsService.selectReductionOilRelationsList(reductionOilRelations);
        ExcelUtil<ReductionOilRelations> util = new ExcelUtil<ReductionOilRelations>(ReductionOilRelations.class);
        return util.exportExcel(list, "reductionOilRelations");
    }

    /**
     * 获取立减活动和油品关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('market:reductionOilRelations:query')")
    @GetMapping(value = "/{activityOilId}")
    public AjaxResult getInfo(@PathVariable("activityOilId") Long activityOilId)
    {
        return AjaxResult.success(reductionOilRelationsService.selectReductionOilRelationsById(activityOilId));
    }

    /**
     * 新增立减活动和油品关系
     */
    @PreAuthorize("@ss.hasPermi('market:reductionOilRelations:add')")
    @Log(title = "立减活动和油品关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReductionOilRelations reductionOilRelations)
    {
        return toAjax(reductionOilRelationsService.insertReductionOilRelations(reductionOilRelations));
    }

    /**
     * 修改立减活动和油品关系
     */
    @PreAuthorize("@ss.hasPermi('market:reductionOilRelations:edit')")
    @Log(title = "立减活动和油品关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReductionOilRelations reductionOilRelations)
    {
        return toAjax(reductionOilRelationsService.updateReductionOilRelations(reductionOilRelations));
    }

    /**
     * 删除立减活动和油品关系
     */
    @PreAuthorize("@ss.hasPermi('market:reductionOilRelations:remove')")
    @Log(title = "立减活动和油品关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityOilIds}")
    public AjaxResult remove(@PathVariable Long[] activityOilIds)
    {
        return toAjax(reductionOilRelationsService.deleteReductionOilRelationsByIds(activityOilIds));
    }
}
